$(function(){
    console.log('来自于demo01');

    $('.demo01 p').click(function(){
        toastr.info('您点击了demo01的内容');
    });

    //fly
    var offset = $(".cart span").offset();
    $("#flyDemo img").click(function(event) {
        var img = $(this).attr('src'); //获取当前点击图片链接
        var flyer = $('<img class="flyer-img" src="' + img + '">'); //抛物体对象
        flyer.fly({
            start: {
                left: event.pageX,//抛物体起点横坐标
                top: event.pageY //抛物体起点纵坐标
            },
            end: {
                left: offset.left + 10,//抛物体终点横坐标
                top: offset.top + 10, //抛物体终点纵坐标
            },
            onEnd: function() {
                this.destory(); //销毁抛物体
            }
        });
    });

    //初始化checkbox
    $('.demo01 :checkbox').iCheck({
        checkboxClass: 'icheckbox_square-red',
        increaseArea: '20%' // optional
    });

    //全选
    $.iCheckAll({
        checkboxClass: 'icheckbox_square-red',
        prefix: 'check'
    });

    //年月日
    new YMDselect('year', 'month', 'day');

    //省市区
    $("#dist").distpicker({
        autoSelect: false,
        valueType: 'code'
    });

    //上传文件
    $('#uploading').upload({
        url: 'url',
        beforeSubmit: function () {
            toastr.info('beforeSubmit');
        },
        success: function (res) {
            toastr.success('上传成功');
        },
        error: function () {
            toastr.error('上传失败');
        }
    });

    //cache
    $('#cacheBtn1').click(function(){
        //localStorage
        $.Cache.set('cache1', 'cache1', 0);

        console.log($.Cache.get('cache1'));
    });

    $('#cacheBtn2').click(function(){
        //sessionStorage
        $.Cache.set('cache2', 'cache2');

        console.log($.Cache.get('cache2'));
    });

    $('#cacheBtn3').click(function(){
        //cookie
        $.Cache.set('cache3', 'cache3', 0, {});

        console.log($.Cache.get('cache3'));
    });


    //pages
     $('.pages').pages({
         url: '../../src/json/demo01.json',
         get: $.http.get.bind($.http)
     }, function (data) {
        console.log(data)
     });

});